<template>
  <app-page>
    <div class="user_index">
      <div class="user_content">
        <div class="title">账户设置</div>
        <div class="user_vip">
          <div class="vip_detail">
            <img src="@/assets/user/icon-vip.png" style="width: 40px; height: 40px" alt="" />
            <!-- <div class="vip_text">会员有效期至：2024.12.31</div> -->
          </div>
        </div>
        <div class="user_list">
          <div class="user_item">
            <div class="user_item_label">头像</div>
            <div class="user_item_content">
              <div class="avatar">{{ userStore.user ? getFirstLetter(userStore.user.user_name) : '' }}</div>
            </div>
          </div>
          <div class="user_item">
            <div class="user_item_label">用户名</div>
            <div class="user_item_content" style="flex: 1">{{ userStore.user ? userStore.user.user_name : '' }}</div>
            <div class="user_item_button">修改</div>
          </div>
          <div class="user_item">
            <div class="user_item_label">用户ID</div>
            <div class="user_item_content" style="flex: 1">{{ userStore.user ? userStore.user.uid : '' }}</div>
            <div class="user_item_button">复制</div>
          </div>
          <div class="user_item">
            <div class="user_item_label">退出当前账号，不再使用</div>
            <div class="user_item_button" style="flex: 1">
              <div class="loginout" @click="userStore.logout()">退出登录</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </app-page>
</template>

<script setup>
const userStore = useUserStore()

const getFirstLetter = str => {
  return str.trim().charAt(0)
}
</script>

<style lang="scss" scoped>
.user_index {
  width: 100%;
  height: 100%;
  background-color: #fff;
  display: flex;
  padding: 40px 0;
  justify-content: center;
}

.user_content {
  width: 1000px;
  display: flex;
  flex-direction: column;

  .title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
  }

  .user_vip {
    margin-top: 16px;
    width: 100%;
    height: 96px;
    display: flex;
    align-items: flex-end;

    background-image: url('@/assets/user/vip-bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    .vip_detail {
      height: 84px;
      width: 100%;
      display: flex;
      align-items: center;
      margin-left: 24px;

      .vip_text {
        margin-left: 16px;
        font-size: 16px;
        color: #333;
      }
    }
  }

  .user_list {
    margin-top: 40px;
    display: flex;
    flex-direction: column;

    .user_item {
      width: 100%;
      height: 88px;
      display: flex;
      align-items: center;
      border-bottom: 1px solid #ebebeb;

      .user_item_label {
        width: 280px;
        font-size: 16px;
        color: #333;
      }

      .user_item_content {
        font-size: 16px;
        font-weight: 600;
        color: #333;

        .avatar {
          width: 56px;
          height: 56px;
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 32px;
          font-weight: 600;
          color: #fff;
          cursor: pointer;

          background-image: url('@/assets/menu/touxiang.png');
          background-size: cover;
          background-position: center;
          background-repeat: no-repeat;
        }
      }

      .user_item_button {
        font-size: 16px;
        color: var(--pcmain-color);
        cursor: pointer;
        display: flex;
        justify-content: end;

        .loginout {
          width: 108px;
          height: 40px;
          background-color: #f5f5f5;
          font-size: 16px;
          color: #333;
          display: flex;
          justify-content: center;
          align-items: center;
          cursor: pointer;
        }
      }
    }
  }
}
</style>
